package com.wwdx.service.impl;

import com.wwdx.BaseCommons;
import com.wwdx.dao.BaseDaoI;
import com.wwdx.service.BaseServiceI;

import javax.annotation.Resource;
import java.io.Serializable;
import java.lang.reflect.ParameterizedType;
import java.math.BigInteger;
import java.util.List;
import java.util.Map;

/**
 * @author liguoliang
 * @date 2017/12/20 16:04
 */
public class BaseServiceImpl<T> extends BaseCommons implements BaseServiceI<T> {

    private BaseDaoI<T> baseDao;

    @Resource
    public void setBaseDao(BaseDaoI<T> baseDao) {
        this.baseDao = baseDao;
    }

    @Override
    public Serializable save(T o) {
        return baseDao.save(o);
    }

    @Override
    public void delete(T o) {
        baseDao.delete(o);
    }

    @Override
    public void update(T o) {
        baseDao.update(o);
    }

    @Override
    public void saveOrUpdate(T o) {
        baseDao.saveOrUpdate(o);
    }

    @Override
    public void merge(T o){
        baseDao.merge(o);
    }

    @Override
    public T getById(Serializable id) {
        Class<T> c = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
        return baseDao.getById(c, id);
    }

    @Override
    public T getByHql(String hql) {
        return baseDao.getByHql(hql);
    }

    @Override
    public T getByHql(String hql, Map<String, Object> params) {
        return baseDao.getByHql(hql, params);
    }

    @Override
    public List<T> find(String hql) {
        return baseDao.find(hql);
    }

    @Override
    public List<T> find(String hql, Map<String, Object> params) {
        return baseDao.find(hql, params);
    }

    @Override
    public List<T> find(String hql, int page, int rows) {
        return baseDao.find(hql, page, rows);
    }

    @Override
    public List<T> find(String hql, Map<String, Object> params, int page, int rows) {
        return baseDao.find(hql, params, page, rows);
    }

    @Override
    public List get(String hql) {
        return baseDao.get(hql);
    }

    @Override
    public List get(String hql, Map<String, Object> params) {
        return baseDao.get(hql, params);
    }

    @Override
    public List get(String hql, int page, int rows) {
        return baseDao.get(hql, page, rows);
    }

    @Override
    public List get(String hql, Map<String, Object> params, int page, int rows) {
        return baseDao.get(hql, params, page, rows);
    }

    @Override
    public Long count(String hql) {
        return baseDao.count(hql);
    }

    @Override
    public Long count(String hql, Map<String, Object> params) {
        return baseDao.count(hql, params);
    }

    @Override
    public int executeHql(String hql) {
        return baseDao.executeHql(hql);
    }

    @Override
    public int executeHql(String hql, Map<String, Object> params) {
        return baseDao.executeHql(hql, params);
    }

    @Override
    public List findBySql(String sql) {
        return baseDao.findBySql(sql);
    }

    @Override
    public List findBySql(String sql, int page, int rows) {
        return baseDao.findBySql(sql, page, rows);
    }

    @Override
    public List findBySql(String sql, Map<String, Object> params) {
        return baseDao.findBySql(sql, params);
    }

    @Override
    public List findBySql(String sql, Map<String, Object> params, int page, int rows) {
        return baseDao.findBySql(sql, params, page, rows);
    }

    @Override
    public int executeSql(String sql) {
        return baseDao.executeSql(sql);
    }

    @Override
    public int executeSql(String sql, Map<String, Object> params) {
        return baseDao.executeSql(sql, params);
    }

    @Override
    public BigInteger countBySql(String sql) {
        return baseDao.countBySql(sql);
    }

    @Override
    public BigInteger countBySql(String sql, Map<String, Object> params) {
        return baseDao.countBySql(sql, params);
    }

    @Override
    public List<T> findBySqlToListBean(String sql, Class clazz) {
        return baseDao.findBySqlToListBean(sql,clazz);
    }

    @Override
    public List<T> findBySqlToListBean(String sql, Class clazz, int page, int rows) {
        return baseDao.findBySqlToListBean(sql,clazz,page,rows);
    }

    @Override
    public List<T> findBySqlToListBean(String sql, Class clazz, Map<String, Object> params) {
        return baseDao.findBySqlToListBean(sql,clazz, params);
    }

    @Override
    public List<T> findBySqlToListBean(String sql, Class clazz, Map<String, Object> params, int page, int rows) {
        return baseDao.findBySqlToListBean(sql,clazz,params,page,rows);
    }
}